package com.flame.system.tools.exception;

import com.flame.core.exception.ExceptionLevel;
import com.flame.core.exception.ExceptionMessage;

import java.text.MessageFormat;

/**
 * @author wuxintong
 * @since 2022/10/26
 */
public enum SystemExceptionMessage implements ExceptionMessage {
    DATASOURCE_EXIST("100005", "数据源【{0}】已存在", ExceptionLevel.INFO),
    UNFOUND("100006", "数据源[{0}]未找到", ExceptionLevel.INFO),
    TEST_FAILED("100007", "数据源[{0}]测试链接失败", ExceptionLevel.INFO),
    GENERATE_FAILED_NO_COLUMN("100008", "[{0}]表代码生成失败，没有需要生成的列数据", ExceptionLevel.INFO),
    NO_PRIMARY_KEY_FOUNDED("100009", "代码生成失败，没有找到主键", ExceptionLevel.INFO);

    private String code;

    private String message;

    private ExceptionLevel level;

    SystemExceptionMessage(String code, String message, ExceptionLevel level) {
        this.code = code;
        this.message = message;
        this.level = level;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public String getMessage(Object... args) {
        return MessageFormat.format(this.message, args);
    }

    @Override
    public ExceptionLevel getLevel() {
        return level;
    }
}
